//package com.lzh.runke.core.autoconfigure;
//
//import com.github.pagehelper.PageInterceptor;
//import com.lzh.runke.core.handler.EnumTypeHandler;
//import com.lzh.runke.core.persist.interceptor.BeforeSaveInterceptor;
//import com.lzh.runke.core.persist.interceptor.ParameterMappingHolderInterceptor;
//import com.lzh.runke.core.web_base.enums.BaseEnum;
//import org.apache.ibatis.plugin.Interceptor;
//import org.apache.ibatis.type.TypeHandler;
//import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
//import org.springframework.boot.autoconfigure.AutoConfigureBefore;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import javax.sql.DataSource;
//import java.util.Properties;
//
//@SuppressWarnings("rawtypes")
//@Configuration
//@ConditionalOnSingleCandidate(DataSource.class)
//@AutoConfigureBefore(MybatisAutoConfiguration.class)
//public class MybatisSettingsAutoConfiguration {
//
//    @Bean
//    public TypeHandler<BaseEnum> enumTypeHandler() {
//        return new EnumTypeHandler<>(BaseEnum.class);
//    }
//
//    @Bean
//    public Interceptor beforeSaveInterceptor() {
//        return new BeforeSaveInterceptor();
//    }
//
//    @Bean
//    public Interceptor parameterMapHolderInterceptor() {
//        return new ParameterMappingHolderInterceptor();
//    }
//
//    @Bean
//    public Interceptor PageInterceptor() {
//        // Mybatis 分页拦截
//        Interceptor pageInterceptor = new PageInterceptor();
//        Properties properties = new Properties();
//        properties.setProperty("helperDialect", "postgresql");
//        properties.setProperty("offsetAsPageNum", "false");
//        properties.setProperty("rowBoundsWithCount", "true");
//        properties.setProperty("pageSizeZero", "false");
//        properties.setProperty("reasonable", "false");
//        properties.setProperty("params", "pageNum=pageNo;pageSize=pageSize;count=countSql;reasonable=reasonable;pageSizeZero=pageSizeZero");
//        properties.setProperty("supportMethodsArguments", "true");
//        properties.setProperty("autoRuntimeDialect", "false");
//        properties.setProperty("closeConn", "true");
//        pageInterceptor.setProperties(properties);
//        return pageInterceptor;
//    }
//
//}
